package com.ryan.dispatcher;

import com.ryan.ohos.extension.gesture.ScaleGestureDetector;
import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.app.Context;
import ohos.multimodalinput.event.TouchEvent;

public class ScaleText extends Text implements Component.TouchEventListener, ScaleGestureDetector.OnScaleGestureListener {

    private final ScaleGestureDetector detector;

    public ScaleText(Context context) {
        this(context, null);
    }

    public ScaleText(Context context, AttrSet attrSet) {
        this(context, attrSet, null);
    }

    public ScaleText(Context context, AttrSet attrSet, String styleName) {
        super(context, attrSet, styleName);
        setTouchEventListener(this);

        detector = new ScaleGestureDetector(getContext(), this);
    }

    @Override
    public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
        return detector.onTouchEvent(touchEvent);
    }

    @Override
    public boolean onScale(ScaleGestureDetector detector) {
        return true;
    }

    @Override
    public boolean onScaleBegin(ScaleGestureDetector detector) {
        return true;
    }

    @Override
    public void onScaleEnd(ScaleGestureDetector detector) {

    }
}
